﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Ganaye.EmbeddedDb
{
    class TableDefinition : ISimpleSerializable
    {
        public byte VerNumber;
        public DateTime LastUpdate;
        public UInt32 NbRecords;
        public UInt16 HeaderWidth;
        public UInt16 RecordWidth;
        public byte IncompleteTransaction;
        public byte EncryptionFlag;
        public byte[] LanOnly;
        public byte Indexed;
        public byte Language;

        public TableDefinition()
        {
            mColumns = new List<ColumnDefinition>();
        }

        #region ISimpleSerializable Members

        public int SerializationBufferSize()
        {
            return 32;
        }

        public void Serialize(SimpleSerializer context)
        {
            context.SerializeByte(ref VerNumber);
            context.SerializeYMD(ref LastUpdate);
            context.SerializeUInt32(ref NbRecords);
            context.SerializeUInt16(ref HeaderWidth);
            context.SerializeUInt16(ref RecordWidth);
            context.Skip(2);
            context.SerializeByte(ref IncompleteTransaction);
            context.SerializeByte(ref EncryptionFlag);
            context.Skip(12); // LanOnly
            context.SerializeByte(ref Indexed);
            context.SerializeByte(ref Language);
            context.Skip(2);
            
        }

        #endregion ISimpleSerializable Members
        private List<ColumnDefinition> mColumns;

        public List<ColumnDefinition> Columns
        {
            get { return mColumns; }
        }


    }
}
